package com.atguigu.sort;

import com.atguigu.utils.ArrayGenerator;
import com.atguigu.utils.SortingHelper;
import com.sun.javafx.collections.SortHelper;
import org.junit.Test;

import java.util.Arrays;


public class MergeSortTest {

    @Test
    public void testMergeSort(){
        Integer[] array = ArrayGenerator.generateRandomArray(100, 100);
        MergeSort.Sort(array);
        boolean b = SortingHelper.isSorted(array);
        System.out.println(b);
    }
    @Test
    public void testMergeSort2(){
        Integer[] array1 = ArrayGenerator.generateRandomArray(100000, 100000);
        Integer[] array2 = ArrayGenerator.generateRandomArray(100000, 100000);
        Integer[] array3 = ArrayGenerator.generateRandomArray(100000, 100000);
        Integer[] array4 = ArrayGenerator.generateRandomArray(100000, 100000);
        SortingHelper.sortTest("MergeSort",array1);
        SortingHelper.sortTest("SelectionSort",array2);
        SortingHelper.sortTest("InsertionSort",array3);
        SortingHelper.sortTest("QuickSort",array4);
    }
    @Test
    public void testPrint(){
        Integer[]arr={99,67,34,90,23,14,67,34,89};
        MergeSort.Sort4(arr);
        System.out.println(Arrays.toString(arr));
    }
    @Test
    public void testMergeSort3(){
        int n=100000;
        Integer[] array2 = ArrayGenerator.generateRandomArray(n, n);
        Integer[] array3 = ArrayGenerator.generateRandomArray(n, n);
        Integer[] array4 = ArrayGenerator.generateRandomArray(n, n);
        Integer[] array1 = ArrayGenerator.generateRandomArray(n, n);
        SortingHelper.sortTest("MergeSort",array2);
        SortingHelper.sortTest("MergeSort2",array3);
        SortingHelper.sortTest("MergeSort3",array4);
        SortingHelper.sortTest("MergeSortBU",array1);
    }
    @Test
    public void test1(){
        int n=10;
        Integer[] array2 = ArrayGenerator.generateRandomArray(n, n);
        Integer[] array3 = ArrayGenerator.generateRandomArray(n, n);
        SortingHelper.sortTest("InsertionSort",array2);
        SortingHelper.sortTest("MergeSortBU",array3);
    }
    @Test
    public void test2(){
        int res=0;
        long startTime=System.currentTimeMillis();
        for (int i = 0; i < 2100000000; i++) {
            res++;
        }
        long endTime=System.currentTimeMillis();
        System.out.println(res);
        System.out.println("总用时："+(endTime-startTime)+"ms");
    }
}
